<%@ page import="dao.UserDao" %><%--
  Created by IntelliJ IDEA.
  User: 竹康乐
  Date: 2022/11/8
  Time: 17:31
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<html>
<head>
    <title>在线论坛</title>
    <style>
        *{
            margin: 0px;
            padding: 0px;
        }
        .head{
            height: 50px;
            background-color: rgba(1,1,1,0.1);
        }
        .nav{
            float: right;
        }
        .head label{
            display: inline-block;
            padding-left: 20px;
            line-height: 50px;
            letter-spacing: 2px;
            font-size: 14px;
            color: coral;
        }
        .head a{
            display: inline-block;
            padding:0px 10px;
            line-height: 30px;
            margin-top: 8px;
            margin-right: 10px;
            font-size: 12px;
            color: coral;
            text-decoration: none;
            border: 1px solid coral;
            border-radius: 8px;
        }
        img{
            display: inline-block;
            width: 30px;
            height: 30px;
            border-radius: 15px;
            border: 1px solid white;

        }
        .footer{
            text-align: center;
            color: dimgrey;
            font-size: 18px;
        }
        .content{
            margin-top: 20px;
            border-bottom: 1px solid lightgray;
        }
        .content label{
            display: inline-block;
            font-size: 14px;
        }
        .content p,label{
            margin-left: 20px;
            margin-top: 8px;
            color: dimgrey;

        }
        .content a{
            text-decoration: none;
        }
        .content a:hover{
            text-decoration: underline dimgrey solid;
        }
        label a{
            text-decoration: none;
            color: coral;
        }
        label a:hover{
            text-decoration: coral underline solid;
        }


    </style>
</head>
<body>

<div class="head">
    <label>在线论坛</label>
    <div class="nav">
        <c:if test="${sessionScope.login_user==null}">
            <a href="/login">登录</a>
            <a href="/register">注册</a>
        </c:if>
        <c:if test="${sessionScope.login_user!=null}">
            <img src="${sessionScope.login_user.avatar}" alt="未知图片">
            <a href="/article/create">写文章</a>
            <a href="/article/out">退出登录</a>
        </c:if>
    </div>
</div>

<c:forEach items="${requestScope.articles}" var="a">
    <c:if test="${a.status==0}">
    <div class="content">
        <a href="/article/detail?id=${a.id}"><p class="title">${a.title}</p></a>
        <p class="summary">${a.summary}</p>
        <label>作者：${a.user.nickname}</label>
        <label>
            点赞量：${a.liketotal}
            <a href="/people/like?id=${a.id}">👍</a>
            阅读量：${a.looktotal}
            <c:if test="${a.user.id==sessionScope.login_user.id}">
                &nbsp;&nbsp;&nbsp;
                <a href="/article/update?id=${a.id}">编辑</a>
                <a href="/article/delete?id=${a.id}">删除</a>
                &nbsp;&nbsp;&nbsp;
            </c:if>
            发布时间：<fmt:formatDate value="${a.addtime}" pattern="yyyy-mm-dd HH:MM"></fmt:formatDate>
        </label>
    </div>
</c:if>
</c:forEach>


<div class="footer">
    <p>下午好${sessionScope.login_user.nickname},当前系统用户共${requestScope.userTotal}人</p>
</div>

</body>
</html>
